<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
<style type="text/css">
.ftitle{
    font-size:14px;
    font-weight:bold;
    padding:5px 0;
    margin-bottom:10px;
    border-bottom:1px solid #ccc;
}
.fitem{
    margin-bottom:10px;
}
.fitem label{
    display:inline-block;
    text-align:right;
    width: 19%;
}
</style>
</head>
<body style="padding: 5px">
<form id="form1" method="post">
	<input id="e_id" name="id" class="mini-hidden" value="" />
	<div class="ftitle">库位</div>
	<div class="fitem">
	    <span>仓库：</span>
		<input name="warehouseId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" 
	    	url="warehouse_hopital_list.do" required="true" allowInput="true" onvalidation="onComboValidation"/>
		<span>&nbsp;货架：</span>
		<input name="shelfNum" class="mini-textbox" required="true" emptyText="请输入货架编号" style="width: 70px"/>
		<span>&nbsp;层：</span>
		<input name="layer" class="mini-textbox" required="true" style="width: 60px"/>
		<span>&nbsp;位：</span>
		<input name="positionNum" class="mini-textbox" required="true" style="width: 60px"/>
	</div>
	<div class="ftitle">存放药品</div>
	<div class="fitem">
		<span>药品名称：</span>
		<input id="medicals" name="medicals" class="mini-textboxlist" style="width:80%;" textField="name" valueField="id"
	    	url="medical_like_find.do"/>
	</div>
</form>
<div style="text-align:center;padding:5px;">
    <a class="mini-button" onclick="javascript:SaveData()" style="width:60px;margin-right:20px;">确定</a>       
    <a class="mini-button" onclick="javascript:window.CloseOwnerWindow();" style="width:60px;">取消</a>       
</div>
<script type="text/javascript">
mini.parse();
var form = new mini.Form("form1");
$("#e_id").val("");
//标准方法接口定义
function SetData(row) {
	//跨页面传递的数据对象，克隆后才可以安全使用
	row = mini.clone(row);
	form.setData(row);
	form.setChanged(false);
	var tbox = mini.get("medicals");
	tbox.setText(row.medicineSets);
}

function SaveData() {
    var o = form.getData();
    form.validate();
    if (form.isValid() == false) return;
    $.ajax({
        url: "shelf_edit_save.do",
		type: 'post',
		dataType: 'json',
        data: o,
        cache: false,
        success: function (text) {
            if(text.success){
            	window.CloseOwnerWindow("succ");
            }else{
            	mini.alert("数据错误！");
            }
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(jqXHR.responseText);
            window.CloseOwnerWindow();
        }
    });
}

function onComboValidation(e) {
    var items = this.findItems(e.value);
    if (!items || items.length == 0) {
        e.isValid = false;
        e.errorText = "输入值不在下拉数据中";
    }
}
</script>
</body>
</html>